<?php

include_once(OBJECT_PATH . "/Product.php");
include_once(DAO_PATH . "/ProductDAO.php");
include_once("UCController.php");

class UCAddProduct implements UCController
{
	function run()
	{
		// objects to be utilised during this use case
		$product = new Product();
		$dao = new ProductDAO();

		// get the variables from the php POST method
		$product->setName($_REQUEST['name']);
		$product->setDescription($_REQUEST['description']);
		$product->setPrice($_REQUEST['retailprice']);
                $product->setComponentIdList($_REQUEST['component']);


		// send the new component to the dao process the result
		$result= $dao->addProduct($product);
		if ($result == true)
		{
			echo "New product successfully added";
		}
		else
		{
			echo "Error detected, the operation was unsuccessful";
		}
	}
}

?>